<?php
/**
 *	@name		商品拍卖
 *	@author		Jeffery
 *	@qq			1017756891
 *	@email		1017756891@qq.com
 *	@website	http://www.iweitao.net
**/
require_once "core.php";

if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) { //安全判断
	exit('Access Denied');
}
if($core->_get('ac') && $core->_get('acdo',1)) { 
	DB::query("DELETE  FROM `".DB::table("paipai_goods")."` WHERE `tid` = '".$core->_get('acdo',1)."'");
	cpmsg("删除成功",'','succeed');
}
$query = DB::query("SELECT * FROM `".DB::table("paipai_goods")."`");
while($fetch = mysql_fetch_array($query)) {
	$time = $_G['timestamp'];
	if($fetch['data_end'] > $time) {
		$time = $fetch['data_end'] - $fetch['data_start'];
		$time = $time/24/60/60;
		$time = ceil($time);
		$str = "距离交易结束还有&nbsp;".$time."&nbsp;天";
	} else if($fetch['data_start'] > $time){
		$time = $fetch['data_start'] - $fetch['data_end'];
		$time = $time/24/60/60;
		$time = ceil($time);
		$str = "距离交易开始还有&nbsp;".$time."&nbsp;天";
	} else {
		$str = "交易已经结束，感谢您的关注";
	}
	if($time > $fetch['data_end']) {
		$end = "<button type='button' class='pn' id='checkout' ><strong>结算交易</strong></button>";
	}
	$data_start = date('Y-m-d H:i:s',$fetch['data_start']);
	$data_end = date('Y-m-d H:i:s',$fetch['data_end']);
	$array[] = array(
		'gid' => $fetch['gid'],
		'tid' => $fetch['tid'],
		'uid' => $fetch['uid'],
		'username' => $fetch['username'],
		'type' => $fetch['type'],
		'made' => $fetch['made'],
		'title' => $fetch['title'],
		'price' => $fetch['price'],
		'add_price' => $fetch['add_price'],
		'send' => $fetch['send'],
		'focus' => $fetch['focus'],
		'focus2' => $fetch['focus2'],
		'focus3' => $fetch['focus3'],
		'focus4' => $fetch['focus4'],
		'focus5' => $fetch['focus5'],
		'data_start' => $data_start,
		'data_end' => $data_end,
		'status' => $fetch['status'],
	);
}
showtableheader();
echo "<tr><td>用户名</td><td>商品名称</td><td>价格</td><td>开始时间</td><td>结束时间</td><td colspan='2'>管理操作</td></tr>";
foreach($array as $k => $v) {
	echo "<tr>";
	echo "<td>".$v['username']."</td>";
	echo "<td>".$v['title']."</td>";
	echo "<td>".$v['price']."</td>";
	echo "<td>".$v['data_start']."</td>";
	echo "<td>".$v['data_end']."</td>";
	echo "<td><a target='_blank' href='forum.php?mod=viewthread&tid=".$v['tid']."'>查看详情</a></td>";
	echo "<td><a href='admin.php?action=plugins&operation=config&do=$pluginid&identifier=iweitao_paipai&pmod=admin&ac=delete&acdo=".$v['tid']."'>删除商品</a></td>";
	echo "</tr>";
}
showtablefooter();
?>